package com.example.myapplication.apter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.Config.TokenBean;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.LawyerdetailsBean;
import com.example.myapplication.ShuJu.UserevaluationBean;

import java.util.List;

public class UserevaluationlawyerApter extends  RecyclerView.Adapter<UserevaluationlawyerApter.Myhot>{
    private Context context;
    private List<UserevaluationBean.RowsBean> list;


    public UserevaluationlawyerApter(Context context,List<UserevaluationBean.RowsBean>list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public UserevaluationlawyerApter.Myhot onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_userevaluationlawyer, null);
        return new UserevaluationlawyerApter.Myhot(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull UserevaluationlawyerApter.Myhot holder, int position) {
        Glide.with(context).load(TokenBean.IP+list.get(position).getFromUserAvatar()).into( holder.img_awyerlistpage);
        holder.name_awyerlistpage.setText(list.get(position).getFromUserName());
        holder.content_awyerlistpage.setText( list.get(position).getEvaluateContent());
        holder.num_awyerlistpage.setText(String.valueOf(list.get(position).getLikeCount()));
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class Myhot extends RecyclerView.ViewHolder{

        private final ImageView img_awyerlistpage;
        private final TextView name_awyerlistpage;
        private final TextView content_awyerlistpage;
        private final TextView num_awyerlistpage;

        public Myhot(@NonNull View itemView) {
            super(itemView);
            img_awyerlistpage = itemView.findViewById(R.id.img_awyerlistpage);
            name_awyerlistpage = itemView.findViewById(R.id.name_awyerlistpage);
            content_awyerlistpage = itemView.findViewById(R.id.content_awyerlistpage);
            num_awyerlistpage = itemView.findViewById(R.id.num_awyerlistpage);
        }
    }
}


